function goto_page(page_name){

    if(page_name){
        if(page_name.indexOf('.') != -1){
            document.location.href = page_name;
        }
        else{
            alert("Invalid page name is received.");
        }
    }
    else{
        document.location.reload();
    }

    return;
}

function get_courses(course_type){
    var ct;
    $.post('/Coursity/course/list', {listType:course_type}, function(result){    
        if(!result.status){alert(result.errorStr);}
        else{
            $('#'+course_type).html('');
			
            if(result.body.length>0){
                ct = '';
                for(var i=0; i<result.body.length; i++){
                    ct += '<div class="course">';
                    ct += '<a href="course_details.html?cid=' + result.body[i].courseId + '">' + result.body[i].courseName + ' </a><br />';
                    ct += 'Start Date: ' + result.body[i].startingDate + '<br />';
                    ct += result.body[i].courseDescription;
                    ct += '</div>';
                }
            }
            else{
                ct += '<p>No course has been found.</p>';
            }
            $('#'+course_type).html(ct);
        }
    }, 'json');
}

function get_tags(place_holder,cid){

    var ph = place_holder;

    $.post('/Coursity/'+place_holder+'/list', '', function(result){
        if(!result.status){alert(result.error);}
        else{

            $('#'+place_holder).html('');
            if(result.body.length>0){
                ph = '<ul>';
                for(var i=0; i<result.body.length; i++){
                    ph += '<li><a href="search_list.html?cid='+cid+'&iid=' + result.body[i].id + '">' + result.body[i].name + '</a></li>';
                }
                ph += '</ul>';
            }
            else{
                ph += '<p>No data has been found.</p>';
            }
            $('#'+place_holder).html(ph);
        }
    }, 'json');
}